 
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:osg/controllers/custom_widget.dart';
import 'package:osg/controllers/http.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:url_launcher/url_launcher.dart';




class MallWallet extends StatefulWidget {
   MallWallet({super.key});

  @override
  State<MallWallet> createState() => _SettingPageState();
}
class _SettingPageState extends State<MallWallet> {

  RxMap infoData={}.obs;

  getInfo(){
     Get.find<HTTPS>().getData('/wallet/walletStatus',{},'noload').then((res) {
      if (res['code']==11000) {
          PayWidget('需实名后才能开通钱包，现在去实名？','1');
      }else{
        infoData.value = res;
       // PayWidget('需实名后才能开通钱包，现在去实名？');
      }
      print(res['code']);
    });
  }

  RxString HFURL=''.obs;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      getInfo();
       Get.find<HTTPS>().getData('/wallet/createWallet', {'url':"back.html?web=wode",}).then((res) {
      if(res!=null)  {
          HFURL.value = res;
      }
    });
    });
    
   
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
           appBar: AppBar(
            backgroundColor: Color(0xffffffff),
            title: Text('我的钱包'),
            centerTitle: true
          ),
          body: 
          ListView(
             padding: EdgeInsets.symmetric(horizontal: 15),
             children: [
                GestureDetector(
                  onTap: () {
                       if(kIsWeb) {
                           final uur=  Uri.parse(HFURL.value);
                            launchUrl(uur,webOnlyWindowName: '_self',
                        );
                        }else{
                         Get.toNamed('/webview?url=$HFURL');
                   }
                  },
                  child:Image.asset('static/web/hf.png',fit: BoxFit.fitWidth,width: double.infinity,),
                )
                 ,
                 SizedBox(height: 10,),
               GestureDetector(
                onTap: (){
                Get.dialog(
                AlertDialog(
                  backgroundColor: Colors.transparent,
                  content: Stack(
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.circular(15.0),
                        child: Image.asset(
                          'static/qidai.png',
                          width: 250,
                          fit: BoxFit.fitWidth,
                        ),
                      ),
                    ],
                  ),
                ),
              );
                },
                child:  Image.asset('static/kuanfutong.png',fit: BoxFit.fitWidth,),
               ),

                 SizedBox(height: 10,),
               GestureDetector(
                onTap: (){
                Get.dialog(
                AlertDialog(
                  backgroundColor: Colors.transparent,
                  content: Stack(
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.circular(15.0),
                        child: Image.asset(
                          'static/qidai.png',
                          width: 250,
                          fit: BoxFit.fitWidth,
                        ),
                      ),
                    ],
                  ),
                ),
              );
                },
                child:  Image.asset('static/yibao.png',fit: BoxFit.fitWidth,),
               ),
                SizedBox(height: 10,),
               GestureDetector(
                onTap: (){
                Get.dialog(
                AlertDialog(
                  backgroundColor: Colors.transparent,
                  content: Stack(
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.circular(15.0),
                        child: Image.asset(
                          'static/qidai.png',
                          width: 250,
                          fit: BoxFit.fitWidth,
                        ),
                      ),
                    ],
                  ),
                ),
              );
                },
                child:  Image.asset('static/yifu.png',fit: BoxFit.fitWidth,),
               ),
                
          ],)
          ,
    );
  }
}